package com.leoren.run.utils;

import com.amap.api.maps.model.LatLng;
import com.leoren.run.vo.RecordPath;
import com.leoren.run.vo.RoutePath;

import java.util.List;

/**
 * 自己的地图Util
 */
public class MyMapUtils {

    private static String MY_WEB_KEY = "afe510b229ad9abc542b563b91f5cca7";

    private static String PICTURE_HEAD = "https://restapi.amap.com/v3/staticmap?";
    private static String PICTURE_PARAM = "&zoom=14&size=400*400&key=" + MY_WEB_KEY + "&paths=2,0x000000,1,,:";

    /**
     * 生成路径的缩略图网络路径
     * @param pathList
     * @return
     */
    public static String GetRoutePicUrl(List<RoutePath> pathList){
        String url = PICTURE_HEAD + PICTURE_PARAM;
        for(int i = 0; i < pathList.size(); i++){
            RoutePath path = pathList.get(i);
            float lng = MyNumberUtils.GetLatLngFormat(path.getQ());
            float lat = MyNumberUtils.GetLatLngFormat(path.getP());
            url = url + lng + "," + lat + ";";
        }
        return url.substring(0, url.length()-1);
    }

    public static String GetPathPicUrl(List<RecordPath> paths){
        String url = PICTURE_HEAD + PICTURE_PARAM;
        for(int i = 0; i < paths.size(); i++){
            RecordPath path = paths.get(i);
            float lng = MyNumberUtils.GetLatLngFormat(path.getLng());
            float lat = MyNumberUtils.GetLatLngFormat(path.getLat());
            url = url + lng + "," + lat + ";";
        }
        return url.substring(0, url.length()-1);
    }

    /**
     * 根据路径获得路径图片Url
     * @param paths
     * @return
     */
    public static String GETPathPicUrl2(List<LatLng> paths){
        String url = PICTURE_HEAD + PICTURE_PARAM;
        for(int i = 0; i < paths.size(); i++){
            LatLng path = paths.get(i);
            float lng = MyNumberUtils.GetLatLngFormat((float) path.longitude);
            float lat = MyNumberUtils.GetLatLngFormat((float) path.latitude);
            url = url + lng + "," + lat + ";";
        }
        return url.substring(0, url.length()-1);
    }

}
